package com.yphone.ui.login.model;

import com.google.gson.reflect.TypeToken;
import com.yphone.net.HttpConstants;
import com.yphone.net.IUIDataListener;
import com.yphone.net.bean.BaseResultWrapper;
import com.yphone.net.helper.ActivityHttpHelper;
import com.yphone.tools.Constants;
import com.yphone.ui.login.bean.request.BaseHttpRequest;
import com.yphone.ui.login.bean.request.VerifiCodeRequestInfo;
import com.yphone.ui.login.bean.respone.VerifiCodeResponeInfo;
import com.yphone.ui.login.contract.VerifiViewContract;


public class VerifiViewModel implements VerifiViewContract.Imodel {
    private ActivityHttpHelper<BaseResultWrapper<String>> httpHelper;

    public void requestVerifiCode(IUIDataListener iuiDataListener, VerifiCodeRequestInfo info, int getVerifiCodeType) {
        try {
            if (this.httpHelper == null) {
                this.httpHelper = new ActivityHttpHelper<>(new TypeToken<BaseResultWrapper<String>>() {
                });
            }
            this.httpHelper.UpdateUIDataListener(iuiDataListener);
            BaseHttpRequest baseHttpRequest = new BaseHttpRequest();
            this.httpHelper.sendPostRequest(HttpConstants.send_mobile_get_code, baseHttpRequest.toMapPrames(info), HttpConstants.TIME_OUT3);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void destory() {
        if (this.httpHelper != null) {
            this.httpHelper.stopRequest();
        }
    }
}